package com.todo.client.gui.dialog;

import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.widget.Dialog;
import com.extjs.gxt.ui.client.widget.button.Button;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.extjs.gxt.ui.client.widget.layout.FormLayout;
import com.google.gwt.core.client.GWT;
import com.todo.client.messages.GUISettings;
import com.todo.client.messages.ToDoAppMessages;

public abstract class AbstractDialog extends Dialog{
	public static final GUISettings SETTINGS = GWT.create(GUISettings.class);
	public static final ToDoAppMessages MESSAGES = GWT.create(ToDoAppMessages.class);
    protected final static String END_OF_STRING = "<br/>";
	
	protected abstract void validate();
	protected abstract boolean hasValue();
		
	protected Button getButton(String value){
		Button button = new Button(value);
		return button;
	}
	protected TextField<String> getTextField(String label){
		TextField<String> field = new TextField<String>();
		field.setFieldLabel(label);
		return field;
	}
	
	protected void getDialog(String title){
		setHeading(title);
		setLayout(getFormLayout());
		setButtonAlign(HorizontalAlignment.LEFT);
        setButtons("");
	}
	
	private FormLayout getFormLayout(){
		FormLayout layout = new FormLayout();
		layout.setLabelWidth(Integer.parseInt(SETTINGS.labelWidth()));
		layout.setDefaultWidth(Integer.parseInt(SETTINGS.defaultWidth()));
		
		return layout;
	}
}
